import {
  exportUrl,
  downloadTemplateUrl,
} from '@/api/outbound/wmsOutTaskScan'
import {
  getAreaCodeList,
  getOrderTypeList,
  getAccountingFlagList,
  getCurrentWarehouseCode,
  getLocationCodeList
} from "@/api/outbound/wmsOutTaskDetail"

import {
  getSnControl,
  getPushStatus,
  getAccountingFlag,
} from '@/api/inbound/wmsInTaskScan'
import {exportExcel} from '@/utils/judge'

// 列表头按钮配置
export const operateList = [
  {
    name: $i18n.t('common.export'),
    type: "primary",
    icon: "el-icon-download",
    handleName: "export", //点击时返回的标识
    url: exportUrl,
    //auth: "auth:operlog:export", //权限字段
  },
  // {
  //   name: $i18n.t("common.add"),
  //   type: "primary",
  //   icon: "el-icon-circle-plus-outline",
  //   handleName: "add", //点击时返回的标识
  // },
  // {
  //   name: $i18n.t("common.delete"),
  //   type: "danger",
  //   icon: "el-icon-delete",
  //   handleName: "deleteBatch", //点击时返回的标识
  //   isMultiple: true, // isSingle 表示必须选择一项//isMultiple: true, // 表示必须多选
  // },
  // {
  //   name: $i18n.t("common.import"),
  //   type: "primary",
  //   icon: "el-icon-circle-plus-outline",
  //   handleName: "import", //点击时返回的标识
  // },
]
// 行末按钮配置
export const rowConfig = [
  {
    name: $i18n.t("common.edit"),
    type: "primary",
    class: "row-btn-primary",
    handleName: "edit", //点击时返回的标识
  },
  {
    name: $i18n.t("common.details"),
    type: "info",
    class: "row-btn-info",
    handleName: "detail", //点击时返回的标识
  },
  {
    name: $i18n.t("common.delete"),
    type: "danger",
    class: "row-btn-danger",
    handleName: "delete", //点击时返回的标识
  },
]
// 搜索条件配置
// 搜索条件配置
export const searchConfig = {
  inline: true,
  formDesc: {
    warehouseCode: {
      type: "select",
      label: $i18n.t("common.warehouse"),
      prop: {
        value: "modelingCode",
        text: "modelingName"
      },
      options: async (data) => {
        const res = await getCurrentWarehouseCode();
        let list = res.data.result || []
        list.forEach(val => {
          val.modelingName = `${val.modelingCode}-${val.modelingName}`
        });
        return list;
      },
    },
    orderNo: {
      type: "input",
      label: $i18n.t("wmsOutTaskScan.orderNo")
    },
    goodsCode: {
      type: "input",
      label: $i18n.t("common.materialCode")
    },
    goodsName: {
      type: "input",
      label: $i18n.t("common.materialName")
    },
    batchNo: {
      type: "input",
      label: $i18n.t("common.batchNo")
    },
    version: {
      type: "input",
      label: $i18n.t("common.version")
    },
    areaCode: {
      type: "select",
      label: $i18n.t("common.areaCode"),
      prop: {
        value: "areaCode",
        text: "areaDesc"
      },
      optionsLinkageFields: ["warehouseCode"],
      options: async (data) => {
        const { warehouseCode } = data
        if (!warehouseCode) return []
        const list = await getAreaCodeList({ warehouseCode: warehouseCode })
        return list.data.result
      }
    },
    locationCode: {
      type: 'input',
      label: $i18n.t('common.locationCode'),  // 库位编码
    },
    // palletCode: {
    //   type: 'input',
    //   label: $i18n.t('wmsInTaskScan.palletCode'),  // 托盘码
    // },
    barcode: {
      type: 'input',
      label: $i18n.t('wmsOutTaskScan.uniqueCode'),  // 产品唯一码
    },
    // printCode: {
    //   type: 'input',
    //   label: $i18n.t('wmsInTaskScan.printCode'),  // 打印码
    // },
    snControl: {
      type: "select",
      label: $i18n.t("wmsOutTaskScan.snControl"),
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getSnControl()
        return list.data.result
      }
    },
    erpStatus: {
      type: "select",
      label: $i18n.t("wmsOutTaskScan.pushStatus"),
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getPushStatus()
        return list.data.result
      }
    },
    erpTime: {
      type: "datetimerange",
      label: $i18n.t("wmsOutTaskScan.pushTime"),
      attrs: {
        valueFormat: "yyyy-MM-dd HH:mm:ss",
        searchArrKey: ["pushTimeMin", "pushTimeMax"]
      }
    },
    accountingFlag: {
      type: 'select',
      label: $i18n.t('wmsOutTaskScan.accountingFlag2'),  // 过账状态
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getAccountingFlag()
        return list.data.result
      }
    },
  },
}
// 新增/删除表单配置
export const formDescDialog = {
  span: 24,
  disabled: false,
  isShowSubmitBtn: true,
  formDesc: {
    outTaskId: {
      type: "number",
      label: $i18n.t("wmsOutTaskScan.outTaskId"),  // 外键
      layout: 12,
      required: false,
    },
    orderId: {
      type: "input",
      label: $i18n.t("wmsOutTaskScan.orderId"),  // 单据行id
      layout: 12,
      required: false,
    },
    orderNo: {
      type: "input",
      label: $i18n.t("wmsOutTaskScan.orderNo"),  // 单据编号
      layout: 12,
      required: false,
    },
    orderDetailId: {
      type: "input",
      label: $i18n.t("wmsOutTaskScan.orderDetailId"),  // 单据明细行id
      layout: 12,
      required: false,
    },
    warehouseCode: {
      type: "input",
      label: $i18n.t("wmsOutTaskScan.warehouseCode"),  // 仓库编码
      layout: 12,
      required: false,
    },
    goodsCode: {
      type: "input",
      label: $i18n.t("wmsOutTaskScan.goodsCode"),  // 商品编码
      layout: 12,
      required: false,
    },
    goodsName: {
      type: "input",
      label: $i18n.t("wmsOutTaskScan.goodsName"),  // 商品名称
      layout: 12,
      required: false,
    },
    amount: {
      type: "number",
      label: $i18n.t("wmsOutTaskScan.amount"),  // 数量
      layout: 12,
      required: false,
    },
    unit: {
      type: "input",
      label: $i18n.t("wmsOutTaskScan.unit"),  // 单位
      layout: 12,
      required: false,
    },
    unitCode: {
      type: "input",
      label: $i18n.t("wmsOutTaskScan.unitCode"),  // 计量单位编码
      layout: 12,
      required: false,
    },
    areaCode: {
      type: "input",
      label: $i18n.t("wmsOutTaskScan.areaCode"),  // 库区编码
      layout: 12,
      required: false,
    },
    locationCode: {
      type: "input",
      label: $i18n.t("wmsOutTaskScan.locationCode"),  // 库位编码
      layout: 12,
      required: false,
    },
    barcode: {
      type: "input",
      label: $i18n.t("wmsOutTaskScan.barcode"),  // 条码
      layout: 12,
      required: true,
    },
    printCode: {
      type: "input",
      label: $i18n.t("wmsOutTaskScan.printCode"),  // 打印码
      layout: 12,
      required: true,
    },
    erpPushCode: {
      type: "input",
      label: $i18n.t("wmsOutTaskScan.erpPushCode"),  // ERP推送校验码: 单号_行号_扫描表id_时间戳
      layout: 12,
      required: false,
    },
    erpStatus: {
      type: "input",
      label: $i18n.t("wmsOutTaskScan.erpStatus"),  // ERP状态 00未推送 01进行中 02 正常 03异常
      layout: 12,
      required: false,
    },
    erpTime: {
      type: "datetime",
      label: $i18n.t("wmsOutTaskScan.erpTime"),  // erp时间
      layout: 12,
      required: false,
      attrs: {
        "valueFormat": "yyyy-MM-dd HH:mm:ss",
      },
    },
    erpMessage: {
      type: "input",
      label: $i18n.t("wmsOutTaskScan.erpMessage"),  // erp返回信息
      layout: 12,
      required: false,
    },
    accountingFlag: {
      type: "input",
      label: $i18n.t("wmsOutTaskScan.accountingFlag"),  // 记账状态0否 1 是
      layout: 12,
      required: false,
    },
    specification: {
      type: "input",
      label: $i18n.t("wmsOutTaskScan.specification"),  // 规格
      layout: 12,
      required: false,
    },
    batchNo: {
      type: "input",
      label: $i18n.t("wmsOutTaskScan.batchNo"),  // 批次号
      layout: 12,
      required: false,
    },
    supplyCode: {
      type: "input",
      label: $i18n.t("wmsOutTaskScan.supplyCode"),  // 供应商编码
      layout: 12,
      required: true,
    },
    supplyName: {
      type: "input",
      label: $i18n.t("wmsOutTaskScan.supplyName"),  // 供应商名称
      layout: 12,
      required: false,
    },
    owner: {
      type: "input",
      label: $i18n.t("wmsOutTaskScan.owner"),  // 货主
      layout: 12,
      required: false,
    },
    validDate: {
      type: "input",
      label: $i18n.t("wmsOutTaskScan.validDate"),  // 有效期
      layout: 12,
      required: false,
    },
    factoryCode: {
      type: "input",
      label: $i18n.t("wmsOutTaskScan.factoryCode"),  // 工厂编码(租户编码)
      layout: 12,
      required: false,
    },
    remark: {
      type: "input",
      label: $i18n.t("wmsOutTaskScan.remark"),  // 备注
      layout: 12,
      required: false,
    },
  },
}
//导入数据
export const importFormDescDialog = {
    span: 24,
    disabled: false,
    isShowSubmitBtn: true,
    formDesc: {
        model: {
            type: "button",
            label: "",
            layout: 24,
            required: false,
            title: $i18n.t("common.downloadTemplate"), // 下载模板
            style: {
                color: '#1867c0',
                fontSize: '14px'
            },
            on: {
                click: () => {
                    exportExcel(downloadTemplateUrl)
                }
            }
        },
        file: {
            type: "input",
            label:$i18n.t("common.chooseFile"),
            layout: 24,
            // required: true,

        },
    }
}

